// pages/Newscoreanalysis/Newscoreanalysis.js
import https from '../../utils/Newrequests'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        menuList: [],
        numberOfJointExaminations: 0,
        schoolReferenceNumber: 0,
        averageScoreOfTheJointExamination: 0,
        schoolAverageScore: 0,
        theHighestScoreInTheJointExam: 0,
        schoolMaximumScore: 0,
        schoolAverageScoreRanking: 0,
        schoolAverageScoreRankingUnified: 0,
        onLine1Score: 0,
        aline: '',
        schoolExcellenceRate: 0,
        schoolPassingRate: 0,
        schoolPassingRateUnified: 0,
        selectMenu: { totalscoreflag: true },  // 示例数据
        launchFlag: true,
        endowFlag: 1,
        schoolAverageScoreRanking1: 0,
        schoolAverageScoreRanking2: 0,
        averageScoreX: [],
        averageScoreY: [],
        averageScoreData: [],
        segmentInterval: 10,
        scoreType: 2,
        subjectId: -1
    },

    /**
     * 生命周期函数--监听页面加载
     */
    async onLoad(options) {
        const { examId, subjectGroup } = options;
        console.log("Exam ID:", examId);
        console.log("Subject Group:", subjectGroup);
        this.setData({
            examId,
            subjectGroup
        });
        await this.getExamSubjectList(examId, subjectGroup);
        await this.getSchoolScoreInfo(this.data.examId, this.data.subjectGroup, this.data.endowFlag);
        await this.getSchoolScoreCompare(this.data.examId, this.data.subjectGroup, this.data.endowFlag)
        await this.getOnlineStatus(this.data.examId, this.data.subjectGroup, this.data.endowFlag)
        await this.getNounSection(this.data.examId, this.data.subjectGroup, this.data.endowFlag)
        await this.getComparison(this.data.examId, this.data.subjectGroup, this.data.endowFlag, this.data.segmentInterval, this.data.scoreType,);
        await this.getScoringAverage(this.data.examId, this.data.subjectGroup, this.data.endowFlag);
    },
    changeMenu(e) {
        const selectedItem = e.detail;  // 子组件传上来的 {id, name, endowScore}
        const subjectId = selectedItem.id;
        const subjectName = selectedItem.name;
        const endowFlag = selectedItem.endowScore;
        this.setData({
            subjectId,
            subjectName,
            endowFlag
        });
        // 判断 id 是否为负数
        if (subjectId < 0) {
            this.setData({
                scoreType: 2
            });
            // 如果 id 是负数，则不传 subjectId
            this.getSchoolScoreInfo(this.data.examId, this.data.subjectGroup, this.data.endowFlag);
            this.getSchoolScoreCompare(this.data.examId, this.data.subjectGroup, this.data.endowFlag)
            this.getComparison(this.data.examId, this.data.subjectGroup, this.data.endowFlag, this.data.segmentInterval, this.data.scoreType)
            this.getScoringAverage(this.data.examId, this.data.subjectGroup, this.data.endowFlag);
            this.getNounSection(this.data.examId, this.data.subjectGroup, this.data.endowFlag);
            this.getOnlineStatus(this.data.examId, this.data.subjectGroup, this.data.endowFlag);
        } else {
            this.setData({
                scoreType: 1
            });
            // 否则传递 subjectId
            this.getSchoolScoreInfo(this.data.examId, this.data.subjectGroup, this.data.endowFlag, subjectId);
            this.getSchoolScoreCompare(this.data.examId, this.data.subjectGroup, this.data.endowFlag, subjectId);
            this.getComparison(this.data.examId, this.data.subjectGroup, this.data.endowFlag, this.data.segmentInterval, this.data.scoreType, subjectId)
            this.getScoringAverage(this.data.examId, this.data.subjectGroup, this.data.endowFlag, subjectId);
            this.getNounSection(this.data.examId, this.data.subjectGroup, this.data.endowFlag, subjectId);
            // this.getOnlineStatus(this.data.examId, this.data.subjectGroup, this.data.endowFlag, subjectId);
        }
        console.log("切换科目：", subjectId, subjectName, endowFlag);
    },
    //得分率对比
    async getScoringAverage(examId, subjectGroup, endowFlag, subjectId = null) {
        let data = { examId, subjectGroup, endowFlag };
        if (subjectId !== undefined && subjectId !== null && subjectId !== '') {
            data.subjectId = subjectId;
        }

        let options = {
            url: '/analysis/total/score/schoolScoreCompare',
            method: 'get',
            data,
            header: { "content-type": "application/json;charset=UTF-8" },
        };

        try {
            let res = await https(options);
            console.log(res.data.data, '得分率原始数据');

            if (res.data.code === 200) {
                const filterComparisonData = res.data.data.filter((item, index) => index > 0);
                console.log(filterComparisonData, '得分率过滤后的数据');

                if (filterComparisonData.length === 0) {
                    console.log('得分率过滤后的数据为空');
                }

                let yDataSchool = [];
                let yDataClass = [];

                let schoolData = filterComparisonData[0];
                const schoolName = Object.keys(schoolData)[0];
                let schoolInfo = schoolData[schoolName];

                console.log(schoolInfo, '得分率学校数据');
                if (schoolInfo && schoolInfo.schoolName) {
                    yDataSchool = [
                        { schoolName: schoolInfo.schoolName, type: "优秀率", value: (Number(schoolInfo.excellentRate) * 100).toFixed(2) },
                        { schoolName: schoolInfo.schoolName, type: "良好率", value: (Number(schoolInfo.goodRate) * 100).toFixed(2) },
                        { schoolName: schoolInfo.schoolName, type: "及格率", value: (Number(schoolInfo.passRate) * 100).toFixed(2) },
                        { schoolName: schoolInfo.schoolName, type: "低分率", value: (Number(schoolInfo.lowScoreRate) * 100).toFixed(2) }
                    ];
                }

                const filterComparisonDataClass = filterComparisonData.filter((item, index) => index > 0);
                filterComparisonDataClass.forEach(item => {
                    Object.keys(item).forEach(classKey => {
                        let classData = item[classKey];
                        if (classData && classData.className) {
                            yDataClass.push({
                                className: classData.className,
                                excellentRate: (Number(classData.excellentRate) * 100).toFixed(2),
                                goodRate: (Number(classData.goodRate) * 100).toFixed(2),
                                passRate: (Number(classData.passRate) * 100).toFixed(2),
                                lowScoreRate: (Number(classData.lowScoreRate) * 100).toFixed(2),
                                excellentCount: classData.excellentCount,
                                goodCount: classData.goodCount,
                                passCount: classData.passCount,
                                lowScoreCount: classData.lowScoreCount
                            });
                        }
                    });
                });

                console.log(yDataSchool, "yDataSchool");
                console.log(yDataClass, "yDataClass");

                this.setData({
                    xDataSSSS: ['优秀', '良好', '及格', '低分'],
                    yDataSchool: yDataSchool,
                    yDataClass: yDataClass
                });

            } else {
                // wx.showToast({
                //     title: res.data.msg || '得分率对比请求失败',
                //     icon: 'none',
                // });
            }
        } catch (error) {
            console.error('得分率对比请求失败:', error);
            // wx.showToast({
            //     title: '得分率对比请求失败',
            //     icon: 'none',
            // });
        }
    },

    //分数段对比
    async getComparison(examId, subjectGroup, endowFlag, segmentInterval, scoreType, subjectId = null) {
        // 组装基础参数
        let data = { examId, subjectGroup, endowFlag, segmentInterval, scoreType };

        // 只有 subjectId 有值时才加入
        if (subjectId !== undefined && subjectId !== null && subjectId !== '') {
            data.subjectId = subjectId;
        }
        let options = {
            url: '/analysis/total/score/scoreSegmentDistribution',
            method: 'get',
            data,
            header: { "content-type": "application/json;charset=UTF-8" },
        };

        try {
            // 发送请求
            let res = await https(options);
            // 如果请求成功，更新科目列表
            if (res.data.code === 200) {
                console.log(res.data.data, '分数段对比数据');
                const filterComparisonData = res.data.data.filter((item, index) => index > 1);
                console.log(filterComparisonData, "过滤后分数段对比的数据");
                // 处理数据：生成班级列表和表头
                const fractionalRangeHead = [];
                const fractionalRangeData = [];

                filterComparisonData.forEach((classData) => {
                    const classId = Object.keys(classData)[0]; // 获取班级ID
                    const segments = classData[classId]; // 获取班级的分数段数据
                    // console.log(classId, "班级id");
                    // console.log(segments, "班级分段数据");

                    // 遍历每个班级的分数段
                    segments.forEach((segment) => {
                        // 如果header中没有当前的segmentInfo，则添加
                        if (!fractionalRangeHead.includes(segment.segmentInfo)) {
                            fractionalRangeHead.push(segment.segmentInfo);
                        }
                    });

                    // 生成班级的数据行
                    const rowData = { school: classId }; // 班级ID
                    segments.forEach((segment, index) => {
                        rowData[fractionalRangeHead[index]] = segment.sameScoreNumber; // 按照分数段添加对应的人数
                    });
                    fractionalRangeData.push(rowData); // 将当前班级的行数据添加到列表
                });

                // 更新页面的数据
                this.setData({
                    fractionalRangeHead, // 分数段的标题
                    fractionalRangeData, // 每个班级对应的数据
                });

            } else {
                // wx.showToast({
                //     title: res.data.msg || '分数段对比请求失败',
                //     icon: 'none',
                // });
            }
        } catch (error) {
            console.error('分数段对比请求失败:', error);
            // wx.showToast({
            //     title: '分数段对比请求失败',
            //     icon: 'none',
            // });
        }
    },
    async getExamSubjectList(examId, subjectGroup) {
        let options = {
            url: '/analysis/total/score/getExamSubjectList',
            method: 'get',
            data: { examId, subjectGroup },
            header: { "content-type": "application/json;charset=UTF-8" },
        };

        try {
            // 发送请求
            let res = await https(options);

            // 如果请求成功，更新科目列表
            if (res.data.code === 200) {
                console.log(res.data.data, '???');

                this.setData({
                    menuList: res.data.data || [],
                });
            } else {
                // wx.showToast({
                //     title: res.data.msg || '科目列表请求失败',
                //     icon: 'none',
                // });
            }
        } catch (error) {
            console.error('科目列表请求失败:', error);
            // wx.showToast({
            //     title: '科目列表请求失败',
            //     icon: 'none',
            // });
        }
    },
    //考试概览
    async getSchoolScoreInfo(examId, subjectGroup, endowFlag, subjectId = null) {
        let data = { examId, subjectGroup, endowFlag };

        // 只有 subjectId 有值时才加入
        if (subjectId !== undefined && subjectId !== null && subjectId !== '') {
            data.subjectId = subjectId;
        }
        let options = {
            url: '/analysis/total/score/schoolScoreInfo',
            method: 'get',
            data,
            header: { "content-type": "application/json;charset=UTF-8" },
        };

        try {
            // 发送请求
            let res = await https(options);

            // 请求成功，更新页面数据
            if (res.data.code === 200) {
                console.log(res.data.data, '学校成绩信息');
                // 提取 scoreLines 中的一档线和二档线
                const scoreLines = res.data.data.scoreLines;
                const schoolAverageScoreRanking1 = scoreLines.length > 0 ? scoreLines[0].onlineNumber : 0; // 一档线人数
                const schoolAverageScoreRanking2 = scoreLines.length > 1 ? scoreLines[1].onlineNumber : 0; // 二档线人数

                const onlineName1 = scoreLines.length > 0 ? scoreLines[0].onlineName : ''; // 一档线名称
                const onlineName2 = scoreLines.length > 1 ? scoreLines[1].onlineName : ''; // 二档线名称
                // this.setData({
                //     // 更新页面的数据
                //     schoolReferenceNumber: res.data.data.mySchoolStats.studentCount,
                //     schoolAverageScore: res.data.data.mySchoolStats.avgScore,
                //     schoolMaximumScore: res.data.data.mySchoolStats.highScore,
                //     schoolAverageScoreRanking: res.data.data.mySchoolStats.avgScoreRank,
                //     onLine1Score: res.data.data.onLine1Score,
                //     aline: res.data.data.aline,
                //     schoolExcellenceRate: res.data.data.mySchoolStats.excellentRate,
                //     schoolPassingRate: res.data.data.mySchoolStats.passRate,
                //     numberOfJointExaminations: res.data.data.examStats.studentCount,
                //     averageScoreOfTheJointExamination: res.data.data.examStats.avgScore,
                //     theHighestScoreInTheJointExam: res.data.data.examStats.highScore,
                //     schoolAverageScoreRankingUnified: res.data.data.examStats.avgScoreRank,
                //     schoolExcellenceRateUnified: res.data.data.examStats.excellentRate,
                //     schoolPassingRateUnified:res.data.data.examStats.passRate,
                //     schoolAverageScoreRanking1, // 一档线人数
                //     schoolAverageScoreRanking2, // 二档线人数
                //     onlineName1, // 一档线名称
                //     onlineName2, // 二档线名称
                // });
                this.setData({
                    scoreLines: res.data.data.scoreLines || [],
                    schoolReferenceNumber: res.data.data.mySchoolStats.studentCount,
                    schoolAverageScore: res.data.data.mySchoolStats.avgScore,
                    schoolMaximumScore: res.data.data.mySchoolStats.highScore,
                    schoolAverageScoreRanking: res.data.data.mySchoolStats.avgScoreRank,
                    onLine1Score: res.data.data.onLine1Score,
                    aline: res.data.data.aline,
                    // schoolExcellenceRate: res.data.data.mySchoolStats.excellentRate,
                    // schoolPassingRate: res.data.data.mySchoolStats.passRate,
                    schoolExcellenceRate: (Number(res.data.data.mySchoolStats.excellentRate) * 100).toFixed(2),
                    schoolPassingRate: (Number(res.data.data.mySchoolStats.passRate) * 100).toFixed(2),
                    numberOfJointExaminations: res.data.data.examStats.studentCount,
                    averageScoreOfTheJointExamination: res.data.data.examStats.avgScore,
                    theHighestScoreInTheJointExam: res.data.data.examStats.highScore,
                    schoolAverageScoreRankingUnified: res.data.data.examStats.avgScoreRank,
                    // schoolExcellenceRateUnified: res.data.data.examStats.excellentRate,
                    // schoolPassingRateUnified: res.data.data.examStats.passRate
                    schoolExcellenceRateUnified: (Number(res.data.data.examStats.excellentRate) * 100).toFixed(2),
                    schoolPassingRateUnified: (Number(res.data.data.examStats.passRate) * 100).toFixed(2)
                });

            } else {
                // wx.showToast({
                //     title: res.data.msg || '考试概览请求失败',
                //     icon: 'none',
                // });
            }
        } catch (error) {
            console.error('考试概览请求失败:', error);
            // wx.showToast({
            //     title: '考试概览请求失败',
            //     icon: 'none',
            // });
        }
    },
    //平均分对比
    async getSchoolScoreCompare(examId, subjectGroup, endowFlag, subjectId = null) {
        let data = { examId, subjectGroup, endowFlag };

        // 只有 subjectId 有值时才加入
        if (subjectId !== undefined && subjectId !== null && subjectId !== '') {
            data.subjectId = subjectId;
        }
        let options = {
            url: '/analysis/total/score/schoolScoreCompare',
            method: 'get',
            data,
            header: { "content-type": "application/json;charset=UTF-8" },
        };

        try {
            // 发送请求
            let res = await https(options);

            // 如果请求成功，过滤数据并更新页面
            if (res.data.code === 200) {
                console.log(res.data.data, '学校成绩比较数据');

                // 过滤掉索引为 0 和 1 的数据
                const filteredData = res.data.data.filter((item, index) => index > 1);
                console.log(filteredData, '过滤后的数据');

                // 提取 xData 和 yData 用于图表
                const xData = filteredData.map(item => item[Object.keys(item)[0]].className); // 提取 className
                const yData = filteredData.map(item => item[Object.keys(item)[0]].avgScore);
                // console.log(xData, "ssss");

                // 提取 list 用于表格显示
                // 这里获取 filteredData 里的每一个对象
                const list = filteredData.map(item => {
                    // 遍历每个对象的键（例如 33 或 31）
                    return Object.keys(item).map(key => {
                        const currentClass = item[key];  // 当前班级数据
                        return {
                            className: currentClass.className,  // 班级名称
                            people: currentClass.studentCount,  // 学生人数
                            maxScore: currentClass.highScore,  // 最高分
                            avgScore: currentClass.avgScore,   // 平均分
                            rank: currentClass.avgScoreRank,   // 排名
                        };
                    }).flat();  // 使用 flat() 将结果扁平化为一个数组
                }).flat();  // 再次扁平化外层数组
                console.log(xData, "父组件的xData");
                console.log(yData, "父组件的yData");
                // 更新数据
                this.setData({
                    averageScoreX: xData,
                    averageScoreY: yData,
                    averageScoreData: list
                });
            } else {
                // wx.showToast({
                //     title: res.data.msg || '平均分对比请求失败',
                //     icon: 'none',
                // });
            }
        } catch (error) {
            console.error('平均分对比请求失败:', error);
            // wx.showToast({
            //     title: '平均分对比请求失败',
            //     icon: 'none',
            // });
        }
    },

    //名次段数据请求
    async getNounSection(examId, subjectGroup, endowFlag, subjectId = null) {
        let data = { examId, subjectGroup, endowFlag };

        // 只有 subjectId 有值时才加入
        if (subjectId !== undefined && subjectId !== null && subjectId !== '') {
            data.subjectId = subjectId;
        }
        let options = {
            url: '/analysis/total/rank/rankSegmentCompare',
            method: 'get',
            data,
            header: { "content-type": "application/json;charset=UTF-8" },
        };

        try {
            let res = await https(options);
            console.log("API Response:", res); // 打印接口返回的数据

            if (res.data.code === 200) {
                const raw = res.data.data || [];
                console.log(raw, "名次段数据"); // 打印名次段数据

                // 检查 raw 数据结构
                if (!Array.isArray(raw) || raw.length === 0) {
                    throw new Error("Invalid data structure, 'raw' is not an array or is empty.");
                }

                // 提取表头：遍历每个对象并收集所有的名次段字段
                const headerSet = new Set();
                raw.forEach(item => {
                    Object.keys(item).forEach(rank => {
                        headerSet.add(rank); // 这里动态收集所有名次段字段
                    });
                });

                // 转换 Set 为数组，确保每个名次段只出现一次
                const header = Array.from(headerSet);
                console.log(header, "表头");

                // 提取所有班级（从 top50 到 top400 中提取所有班级名）
                const allClasses = new Set();
                raw.forEach(item => {
                    header.forEach(rank => {
                        // 确保 rank 存在并且是数组
                        if (Array.isArray(item[rank])) {
                            item[rank].forEach(entry => {
                                Object.keys(entry).forEach(className => {
                                    allClasses.add(className);
                                });
                            });
                        }
                    });
                });
                const headerDisplay = header.map(h => {
                    if (h.startsWith("top")) {
                        const num = h.replace("top", ""); // 提取数字
                        return `前${num}名`;
                    }
                    return h; // 非 top 开头的保持原样
                });
                // console.log(headerDisplay,"格式化表头数据");

                // 转换 Set 为数组
                const classList = Array.from(allClasses);

                // 处理表格数据
                const list = classList.map((className) => {
                    const row = { school: className };
                    header.forEach((rank) => {
                        // 查找该班级在当前名次段中的人数
                        const rankData = raw.find(item => item[rank] && item[rank].some(entry => entry[className]));
                        const count = rankData ? rankData[rank].find(entry => entry[className])[className] : 0;
                        row[rank] = count;
                    });
                    return row;
                });

                // 将数据赋值给页面的 `data`
                this.setData({ header, headerDisplay, list });
            } else {
                // wx.showToast({ title: res.data.msg || '名次段请求失败', icon: 'none' });
            }
        } catch (error) {
            console.error('名次段请求失败:', error);
            // wx.showToast({ title: '名次段请求失败', icon: 'none' });
        }
    },
    // 监听子组件菜单切换事件
    async getOnlineStatus(examId, subjectGroup, endowFlag, subjectId = null) {
        let data = { examId, subjectGroup, endowFlag };
        if (subjectId !== undefined && subjectId !== null && subjectId !== '') {
            data.subjectId = subjectId;
        }
        let options = {
            url: '/analysis/line/online/peopleCompare',
            method: 'get',
            data,
            header: { "content-type": "application/json;charset=UTF-8" },
        };

        try {
            let res = await https(options);
            if (res.data.code === 200) {
                const raw = res.data.data || [];

                // 保存原始数据（没有过滤）
                const originalLinesData = raw.map(obj => {
                    const key = Object.keys(obj)[0];
                    let list = obj[key] || [];
                    return { name: key, list };
                });

                // 处理成 [{name, list}, ...] 结构，并过滤掉特控和二本线中的索引为0的数据
                const linesData = raw.map(obj => {
                    const key = Object.keys(obj)[0];
                    let list = obj[key] || [];


                    const firstClassData = list[0] || {};  // 获取第一个班级数据
                    const firstClassInfo = firstClassData[Object.keys(firstClassData)[0]] || [];  // 获取该班级的数据数组
                    const classInfo = firstClassInfo[0] || {};  // 提取数组中的第一个元素，即班级的实际数据

                    const topDataOnline = {
                        onLineScore: classInfo.lineScore || 0,  // 分数线
                        onReferenceNumber: classInfo.peopleNum || 0,  // 参考人数
                        onLineNum: classInfo.fullScoreLineNum || 0,  // 上线人数
                        onLineRate: classInfo.onlineRate || 0,   // 上线率
                    };
                    const topDataCritical = {
                        onlineRangeScore: classInfo.onlineRangeScore || 0,   // 临界生区间
                        criticalNum: classInfo.criticalNum || 0, //临界生区间共多少名
                    };
                    // 设置顶部数据
                    this.setData({
                        datainfoOnline: topDataOnline,  // 给上线对比用
                        datainfoCritical: topDataCritical, // 给临界生用
                    });

                    // 去掉索引为0的数据，用于表格展示
                    list = list.slice(1);


                    return {
                        name: key,
                        list: list  // 班级数据数组
                    };
                });

                // 默认选中第一条
                this.setData({
                    linesData,        // 所有分数线数据
                    originalLinesData, // 保存原始数据
                    currentIndex: 0,  // 默认选中第一条
                    currentIndexs: 0
                });

                // 默认选中后立即更新顶部信息
                this.updateTopInfo(0);  // 直接更新顶部信息，确保初次加载显示正确
                this.updateTopInfos(0);  // 直接更新顶部信息，确保初次加载显示正确
            } else {
                // wx.showToast({ title: res.data.msg || '上线对比请求失败', icon: 'none' });
            }
        } catch (error) {
            console.error('请求失败:', error);
            // wx.showToast({ title: '上线对比请求失败', icon: 'none' });
        }
    },

    // 更新顶部信息
    updateTopInfo(index) {
        const linesData = this.data.originalLinesData;  // 使用原始数据
        const selectedLineData = linesData[index]?.list || [];

        // 获取第一个班级数据
        const firstClassData = selectedLineData[0] || {};
        const firstClassInfo = firstClassData[Object.keys(firstClassData)[0]] || [];
        const classInfo = firstClassInfo[0] || {};

        const topData = {
            onLineScore: classInfo.lineScore || 0,  // 分数线
            onReferenceNumber: classInfo.peopleNum || 0,  // 参考人数
            onLineNum: classInfo.fullScoreLineNum || 0,  // 上线人数
            onLineRate: classInfo.onlineRate || 0,   // 上线率
        };

        this.setData({
            datainfoOnline: topData,  // 更新顶部信息
        });
    },
    // 更新顶部信息
    updateTopInfos(index) {
        const linesData = this.data.originalLinesData;  // 使用原始数据
        const selectedLineData = linesData[index]?.list || [];

        // 获取第一个班级数据
        const firstClassData = selectedLineData[0] || {};
        const firstClassInfo = firstClassData[Object.keys(firstClassData)[0]] || [];
        const classInfo = firstClassInfo[0] || {};

        const topData = {
            onlineRangeScore: classInfo.onlineRangeScore || 0,   // 临界生区间
            criticalNum: classInfo.criticalNum || 0, //临界生区间共多少名
        };

        this.setData({
            datainfoCritical: topData,  // 更新顶部信息
        });
    },
    onUpdateIndex(e) {
        const index = e.detail; // 获取选中的菜单索引
        this.setData({
            currentIndex: index
        });

        // 调用封装的更新顶部信息的方法
        this.updateTopInfo(index);
    },

    onUpdateIndexs(e) {
        const index = e.detail; // 获取选中的菜单索引
        this.setData({
            currentIndexs: index
        });

        // 调用封装的更新顶部信息的方法
        this.updateTopInfos(index);
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})